<% page_title "Changelog" %>

<%= render 'projects/header', project: @project, tab: "changelog" %>

<section class="tabs table-responsive">
  <form id="date-chooser">
    <p class="form-inline">
      Branch:
      <input type="text" class="form-control" value="<%= @branch.to_s %>" name="branch" id="branch">
      Changes made between
      <input type="text" class="form-control" value="<%= @start_date.to_s %>"  name="start_date" id="start-date"> and
      <input type="text" class="form-control" value="<%= @end_date.to_s %>" name="end_date" id="end-date">
      <span id="status-message" class="btn btn-default hidden"></span>
    </p>
  </form>

  <table class="table table-bordered">
    <thead>
      <tr>
        <th>PR</th>
        <th>Contributers</th>
        <th>JIRA</th>
        <th>Title</th>
        <th>Risks</th>
      </tr>
    </thead>
    <tbody>
      <% @changeset.pull_requests.each do |pr| %>
        <tr>
          <td><%= link_to pr.reference, pr.url %></td>
          <td>
            <% pr.users.each do |user| %>
              <img class="circular" title="<%= user.identifier %>" src="<%= user.avatar_url(50) %>" />
            <% end %>
          </td>
          <td>
            <% if pr.jira_issues.any? %>
              <% pr.jira_issues.each_with_index do |issue, i| %>
                <%= link_to (issue.reference + (i > 0 ? "<br/>" : "")), issue.url %>
              <% end %>
            <% end %>
          </td>
          <td><%= markdown(pr.title_without_jira) %></td>
          <td>
            <% if pr.risky? %>
              <%= markdown(pr.risks) %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
</section>
